home *** CD-ROM | disk | FTP | other *** search
Text File | 1991-03-06 | 3.2 KB | 66 lines | [TEXT/GEOL] |
- Item 5679017 4-April-88 17:05
-
- From: ROSENSTEIN1 Rosenstein, Larry
-
- To: MACAPP$ MacApp Interest List
-
- cc: SHEETS1 Sheets, Steve
-
- Sub: Resource Forks in MacApp
-
- MacApp always tries to save files by making a temporary copy and renaming this
- to the original file name only if the save succeeds. This guarantees that the
- user doesn't lose the original version.
-
- If there is not enough disk space (based on the numbers returned by
- DoNeedDiskSpace) to make a second copy, then MacApp will check to see if there
- would be enough space by deleting the original version. If so, then MacApp
- will ask the user if it is OK to delete the original. (The user can cancel and
- save to a different disk instead.)
-
- You can tell MacApp never to delete the original version by setting the field
- TDocument.fSaveInPlace to sipNever (the default if sipAskUser). In that case,
- the user will get an "out-of-disk-space" message if there is not enough space
- to save a copy. You can tell MacApp to automatically save over the original
- version by setting it to sipAlways. This field is only relevant if there is
- not enough space to make a copy, but there would be if the original was deleted
- first.
-
- One of the 2 methods TDocument.SaveViaTemp and SaveInPlace will be called to do
- the actual save. SaveInPlace must be overridden if you tell MacApp to keep the
- data or resource forks open at all times. These methods call
- TDocument.MakeNewCopy, which does the actual File Manager calls.
-
- SaveInPlace simply deletes the original file, and saves into a file with the
- appropriate name. SaveViaTemp saves into a temporary file, deletes the
- original, and renames the temporary file to the proper name.
-
- You will notice that for all the cases handled by MacApp automatically, the
- application is saving into a brand new file. Sometimes, the original file will
- have been deleted already (the save in place case). If you instruct MacApp to
- keep the data and/or resource fork open, then the original file will be
- available while the new file is being created.
-
- Because of this, MacApp does not support a model where saving a file involves
- making a few changes to resources in the file and the resource fork is simply
- updated. The application must be prepared to copy all the resources out of the
- old file and add them to the new one.
-
- In the case of DrawShapes, the program just reads the resource in DoRead and
- makes a copy of the data. DoWrite copies this data and adds it to the resource
- fork. In both cases, the resource will be freed when MacApp closes the
- resource fork. (When saving, closing the resource fork flushes all the
- resources to disk.)
-
- The constants you mentioned are the overhead for each resource type and for the
- resource file in general. These are provided in MacApp so that your
- DoNeedDiskSpace method can compute the number of bytes your resource fork uses.
- TDocument.DoNeedDiskSpace will add kRsrcFileOverhead to the rsrcForkBytes
- automatically. You need to add kRsrcTypeOverhead for each distinct type you
- create, and kRsrcOverhead for each resource. (This is in addition to the
- number of bytes in the resources themselves.)
-
- Larry Rosenstein
-
-
-